package com.ryenlii.datatrans.core.kafka;

import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

import java.util.Scanner;

/**
 * KafkaProducerDemo
 *
 * @description:
 */
@Component
public class KafkaProducerDemo {

    @Resource
    private KafkaService kafkaService;

    // @PostConstruct
    public void send() throws InterruptedException {
        Scanner sc = new Scanner(System.in);
        String mess;
        boolean flag = true;
        while (flag) {
            System.out.print("生产消息(输入exit 退出): ");
            mess = sc.nextLine();
            if (mess != null && (flag = (!"exit".equals(mess)))) {
                kafkaService.platformSendCityData(mess);
                Thread.sleep(1000);
                System.out.println("send message success....");
            }
        }
    }

}